package com.tulele.vtool.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.tulele.vtool.mapper.VideoInfoMapper;
import com.tulele.vtool.model.BrandInfo;
import com.tulele.vtool.model.LookVideoInfo;
import com.tulele.vtool.model.PlatformSysInfo;
import com.tulele.vtool.model.VideoInfo;
import com.tulele.vtool.model.combinedEntity.*;
import com.tulele.vtool.service.*;
import com.tulele.vtool.task.async.LookArticleAsyncTask;
import com.tulele.vtool.task.async.LookPunchClockArticleAsyncTask;
import com.tulele.vtool.utils.DateUtil;
import com.tulele.vtool.utils.RedisCacheUtil;
import com.tulele.vtool.utils.ToolUtil;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Optional;
import java.util.Set;

@Service
@Slf4j
public class VideoInfoServiceImpl implements IVideoInfoService {

    @Autowired
    private ILookArticleInfoService lookVideoInfoService;

    @Autowired
    private VideoInfoMapper articleInfoMapper;

    @Autowired
    private INewLookArticleCountInfoService newLookVideoCountInfoService;

    @Autowired
    private RedisCacheUtil redisCacheUtil;

    @Autowired
    @Lazy
    private LookArticleAsyncTask lookVideoAsyncTask;

    @Autowired
    @Lazy
    private LookPunchClockArticleAsyncTask lookPunchClockVideoAsyncTask;

//    @Autowired
//    private PlatformSysInfoConfig platformSysInfoConfig;

    @Autowired
    private IUserInfoService userInfoService;

    @Autowired
    private IUserBrandInfoService userBrandInfoService;

    @Override
    public int addWechatVideoInfo(VideoInfo articleInfo) {
        articleInfoMapper.addVideoInfo(articleInfo);
        return articleInfo.getId();
    }

    @Override
    public int modifyWechatVideoInfo(VideoInfo articleInfo) {

        String cacheKey = articleInfo.getId() + "VideoDetailInfoKey";
        redisCacheUtil.removeSingleCache(cacheKey);

        return articleInfoMapper.updateVideoInfo(articleInfo);
    }

    @Override
    public int addUserVideoInfo(VideoInfo articleInfo) {
        return articleInfoMapper.addVideoInfo(articleInfo);
    }

    @Override
    public int modifyUserVideoInfo(VideoInfo articleInfo) {

        String cacheKey = articleInfo.getId() + "VideoDetailInfoKey";
        redisCacheUtil.removeSingleCache(cacheKey);

        return articleInfoMapper.updateVideoInfo(articleInfo);
    }

    @Override
    public VideoInfo getVideoDetailInfo(Integer articleId) {

        String cacheKey = articleId + "VideoDetailInfoKey";
        Object articleDetailInfoInfoObj = redisCacheUtil.getCacheObject(cacheKey);

        VideoInfo articleInfo = new VideoInfo();
        if (articleDetailInfoInfoObj == null) {
            articleInfo = articleInfoMapper.queryVideoDetailInfo(articleId);

            if (articleInfo == null) {

                redisCacheUtil.setCacheObject(cacheKey, new VideoInfo(), 2592000);

            } else {

                redisCacheUtil.setCacheObject(cacheKey, articleInfo, 2592000);

            }

        } else {

            articleInfo = (VideoInfo)articleDetailInfoInfoObj;

        }

        return articleInfo;

    }

    @Override
    public PageInfo<CombinedUserLookOtherVideoInfo> getUserLookOtherVideoInfo(Integer pageNum, Integer pageSize, LookVideoInfo lookVideoInfo) {

        //获取用户查看的文章信息时，把对应的文章查看次数清空
//        NewLookVideoCountInfo newLookVideoCountInfo = new NewLookVideoCountInfo();
//        newLookVideoCountInfo.setUserId(lookVideoInfo.getUserId());
//        newLookVideoCountInfo.setOtherUserId(lookVideoInfo.getOtherUserId());
//        newLookVideoCountInfoService.modifyUserNewLookVideoInfo(newLookVideoCountInfo);
//
//        PageHelper.startPage(pageNum, pageSize);
//        List<CombinedUserLookOtherVideoInfo> userLookOtherVideoInfoList = articleInfoMapper.queryUserLookOtherVideoInfo(lookVideoInfo);
//
//        return new PageInfo<CombinedUserLookOtherVideoInfo>(userLookOtherVideoInfoList);
        return null;
    }

    @Override
    public PageInfo<CombinedVideoInfoByVideoBrand> getVideoInfoByBrand(Integer pageNum, Integer pageSize, Integer userId) {
        PageHelper.startPage(pageNum, pageSize);
        List<CombinedVideoInfoByVideoBrand> articleInfoByVideoBrandList = articleInfoMapper.queryVideoInfoByBrand(userId);

        return new PageInfo<CombinedVideoInfoByVideoBrand>(articleInfoByVideoBrandList);
    }

    @Override
    public PageInfo<CombinedVideoInfoByVideoType> getVideoInfoByVideoType(Integer pageNum, Integer pageSize, Integer articleTypeId) {
        PageHelper.startPage(pageNum, pageSize);
        List<CombinedVideoInfoByVideoType> articleInfoByVideoTypeList = articleInfoMapper.queryVideoInfoByVideoType(articleTypeId);

        return new PageInfo<CombinedVideoInfoByVideoType>(articleInfoByVideoTypeList);
    }

    @Override
    public List<CombinedUserVideoInfoBySpecialSize> getUserVideoInfoBySpecialSize(Integer userId, int recordSize) {
        return articleInfoMapper.queryUserVideoInfoBySpecialSize(userId, recordSize);
    }

    @Override
    public PageInfo<CombinedUserOwnVideoInfo> getUserOwnVideoInfo(Integer pageNum, Integer pageSize, Integer userId) {
        PageHelper.startPage(pageNum, pageSize);
        List<CombinedUserOwnVideoInfo> userOwnVideoInfoList = articleInfoMapper.queryUserOwnVideoInfo(userId);

        return new PageInfo<CombinedUserOwnVideoInfo>(userOwnVideoInfoList);
    }

    @Override
    public int removeUserVideoInfo(VideoInfo articleInfo) {
        String cacheKey = articleInfo.getId() + "VideoDetailInfoKey";
        redisCacheUtil.removeSingleCache(cacheKey);

        return articleInfoMapper.updateVideoInfo(articleInfo);
    }

    @Override
    public Integer getVideoUserInfo(Integer articleId) {
        return articleInfoMapper.queryVideoUserInfo(articleId);
    }

    @Override
    public int lookOtherUserVideo(LookVideoInfo lookVideoInfo, VideoInfo articleInfo, String lookUserNickName, String viewType) {

        log.info("********** VideoInfoServiceImpl lookOtherUserVideo"+",[lookVideoInfo]="+lookVideoInfo.toString()+",[articleInfo]="+articleInfo.toString()+",[lookUserNickName]="+lookUserNickName+",[viewType]="+viewType);
//        VideoInfo queryVideoInfo = new VideoInfo();
//        queryVideoInfo.setShareVideoSourceId(lookVideoInfo.getVideoId());
//        queryVideoInfo.setUserId(lookVideoInfo.getOtherUserId());
//
//        int finalVideoId = Optional.ofNullable(articleInfoMapper.queryUserPlatformVideoShareStatus(queryVideoInfo)).orElse(0);
//        if (finalVideoId > 0) {
//            lookVideoInfo.setVideoId(finalVideoId);
//        }
//
//        lookVideoAsyncTask.lookOtherUserVideo(lookVideoInfo, articleInfo, lookUserNickName, viewType);
//
        return 0;
    }

    @Override
    public List<PlatformRecommendVideoInfo> getPlatformRecommendVideoInfo() {
        return articleInfoMapper.queryPlatformRecommendVideoInfo();
    }

    @Override
    public VideoInfo getSpiderVideoInfoByThirdVideoId(VideoInfo articleInfo) {
        return articleInfoMapper.querySpiderVideoInfoByThirdVideoId(articleInfo);
    }

    @Override
    public Integer getUserPlatformVideoShareStatus(VideoInfo articleInfo) {
        return articleInfoMapper.queryUserPlatformVideoShareStatus(articleInfo);
    }

    @Override
    public Integer getPlatformVideoCountByBrandId(Integer brandId) {
        return articleInfoMapper.queryPlatformVideoCountByBrandId(brandId);
    }

    @Override
    public Integer getPlatformVideoCountByTypeId(Integer typeId) {
        return articleInfoMapper.queryPlatformVideoCountByTypeId(typeId);
    }

    @Override
    public List<VideoInfo> getToBeProcessedSpiderVideoInfo() {
        return articleInfoMapper.queryToBeProcessedSpiderVideoInfo();
    }

    @Override
    public List<PlatformRecommendVideoInfo> getPlatformRecommendVideoInfoByBrand(List<Integer> useBrandIds) {
        return articleInfoMapper.queryPlatformRecommendVideoInfoByBrand(useBrandIds);
    }

    @Override
    public List<PlatformRecommendVideoInfo> getPlatformRecommendVideoInfoByType(Integer articleTypeId) {
        return articleInfoMapper.queryPlatformRecommendVideoInfoByType(articleTypeId);
    }

    @Override
    public List<CombinedVideoInfoByVideoBrand> getVideoInfoByBrandForRand(Integer articleBrandId, int recordSize) {
        String articleBrandIdKey = "platformBrandVideo" + articleBrandId;
        Set<CombinedVideoInfoByVideoBrand> brandVideoInfoSet = redisCacheUtil.getCacheSetForRandomEle(articleBrandIdKey, recordSize);

        List<CombinedVideoInfoByVideoBrand> brandVideoInfoList = Lists.newArrayList();
        if (org.apache.commons.collections.CollectionUtils.isNotEmpty(brandVideoInfoSet)) {

            brandVideoInfoList = Lists.newArrayList(brandVideoInfoSet);

        }

        return brandVideoInfoList;
    }

    @Override
    public List<CombinedVideoInfoByVideoBrand> getVideoInfoByVideoTypeForRand(Integer articleTypeId, int recordSize) {

        String articleTypeIdKey = "platformTypeVideo" + articleTypeId;
        Set<CombinedVideoInfoByVideoBrand> typeVideoInfoSet = redisCacheUtil.getCacheSetForRandomEle(articleTypeIdKey, recordSize);

        List<CombinedVideoInfoByVideoBrand> typeVideoInfoList = Lists.newArrayList();
        if (org.apache.commons.collections.CollectionUtils.isNotEmpty(typeVideoInfoSet)) {

            typeVideoInfoList = Lists.newArrayList(typeVideoInfoSet);

        }

        return typeVideoInfoList;

        //return articleInfoMapper.queryVideoInfoByVideoTypeForRand(articleTypeId, recordSize);
    }

    @Override
    public int pseudoDeleteVideoInfo(Integer articleId) {
        VideoInfo articleInfo = new VideoInfo();
        articleInfo.setId(articleId);
        articleInfo.setVideoStatus(0);
        articleInfo.setModifyTime(DateUtil.getCurDate());
        return articleInfoMapper.updateVideoInfo(articleInfo);
    }

    @Override
    public List<CombinedVideoInfoByVideoBrand> getVideoInfoByUserConcernVideoTypeForRand(List<Integer> articleTypeId, int recordSize) {

        String articleTypeIdKey = "platformTypeVideo" + articleTypeId.get(0);
        Set<CombinedVideoInfoByVideoBrand> typeVideoInfoSet = redisCacheUtil.getCacheSetForRandomEle(articleTypeIdKey, recordSize);

        List<CombinedVideoInfoByVideoBrand> typeVideoInfoList = Lists.newArrayList();
        if (org.apache.commons.collections.CollectionUtils.isNotEmpty(typeVideoInfoSet)) {

            typeVideoInfoList = Lists.newArrayList(typeVideoInfoSet);

        }

        return typeVideoInfoList;

        //return articleInfoMapper.queryVideoInfoByUserVideoTypeForRand(articleTypeId, recordSize);
    }

    @Override
    public String generateUserPushVideoInfo(List<Integer> articleTypeId, int recordSize, PlatformSysInfo platformSysInfoConfig) {

        String articleDetailUrl = platformSysInfoConfig.getArticleDetailUrl();

        StringBuffer wxPushMsg = new StringBuffer();
        wxPushMsg.append("公众号将继续为你推送消息\n\n");

        //List<CombinedVideoInfoByVideoType> articleInfoList = articleInfoMapper.queryVideoInfoByUserVideoTypeForRand(articleTypeId, recordSize);

        List<VideoListShowInfo> articleInfoList = Lists.newArrayList();

        List<VideoListShowInfo> articleListShowInfos_one = articleInfoMapper.queryVideoInfoByVideoTypeForHotScoreBySpecialSize(1, null, 1);

        List<VideoListShowInfo> articleListShowInfos_two = articleInfoMapper.queryVideoInfoByVideoTypeForHotScoreBySpecialSize(4, null, 1);

        List<VideoListShowInfo> articleListShowInfos_three = articleInfoMapper.queryVideoInfoByVideoTypeForHotScoreBySpecialSize(5, null, 1);

        List<VideoListShowInfo> articleListShowInfos_four = articleInfoMapper.queryVideoInfoByVideoTypeForHotScoreBySpecialSize(9, null, 1);

        articleInfoList.addAll(articleListShowInfos_one);
        articleInfoList.addAll(articleListShowInfos_two);
        articleInfoList.addAll(articleListShowInfos_three);
        articleInfoList.addAll(articleListShowInfos_four);

        if (!CollectionUtils.isEmpty(articleInfoList)) {

            articleInfoList.forEach(articleInfo -> {
                wxPushMsg.append("\ue11d<a href='"+ articleDetailUrl + articleInfo.getVideoId() + "'>"+ articleInfo.getVideoTitle() +"</a>\n\n");
            });

        }

        wxPushMsg.append("点击下方 获客爆文，更多爆文");

        return wxPushMsg.toString();
    }

    @Override
    public List<CombinedVideoInfoByVideoBrand> getToBeAddRedisVideoInfoOfBrand() {
        return articleInfoMapper.queryToBeAddToRedisVideoInfoOfBrand();
    }

    @Override
    public List<CombinedVideoInfoByVideoBrand> getToBeRemoveRedisVideoInfoOfBrand() {
        return articleInfoMapper.queryToBeRemoveFromRedisVideoInfoOfBrand();
    }

    @Override
    public List<CombinedVideoInfoByVideoBrand> getToBeAddToRedisVideoInfoOfType() {
        return articleInfoMapper.queryToBeAddToRedisVideoInfoOfType();
    }

    @Override
    public List<CombinedVideoInfoByVideoBrand> getToBeRemoveFromRedisVideoInfoOfType() {
        return articleInfoMapper.queryToBeRemoveFromRedisVideoInfoOfType();
    }

    //@Override
    //public int lookOtherUserPunchClockVideo(LookVideoInfo lookVideoInfo, PunchClockArticleInfo punchClockVideoInfo, String lookUserNickName) {
        //log.info("********** VideoInfoServiceImpl lookOtherUserPunchClockVideo"+",[lookVideoInfo]="+lookVideoInfo.toString()+",[punchClockVideoInfo]="+punchClockVideoInfo.toString()+",[lookUserNickName]="+lookUserNickName);
        //查询是否已经有了查看记录
//        LookVideoInfo lookVideoInfoInDB = lookVideoInfoService.getLookOtherArticleInfo(lookVideoInfo);
//        if (lookVideoInfoInDB == null) {
//
//            LookVideoInfo recordLookVideoInfo = new LookVideoInfo();
//            recordLookVideoInfo.setUserId(lookVideoInfo.getUserId());
//            recordLookVideoInfo.setOtherUserId(lookVideoInfo.getOtherUserId());
//            recordLookVideoInfo.setVideoId(lookVideoInfo.getVideoId());
//            recordLookVideoInfo.setLookCount(1);
//            recordLookVideoInfo.setTodayLookCount(1);
//            recordLookVideoInfo.setVideoCategory(2);
//            recordLookVideoInfo.setCreateTime(DateUtil.getCurDate());
//            recordLookVideoInfo.setModifyTime(DateUtil.getCurDate());
//
//            //不存在，则添加
//            lookVideoInfoService.recordLookArticleInfo(recordLookVideoInfo);
//
//        } else {
//
//            //存在，则修改
//            int lookCount = Optional.ofNullable(lookVideoInfoInDB.getLookCount()).orElse(0);
//            int todayLookCount = Optional.ofNullable(lookVideoInfoInDB.getTodayLookCount()).orElse(0);
//
//            LookVideoInfo modifyLookVideoInfo = new LookVideoInfo();
//            modifyLookVideoInfo.setId(lookVideoInfoInDB.getId());
//            modifyLookVideoInfo.setTodayLookCount(todayLookCount + 1);
//            modifyLookVideoInfo.setLookCount(lookCount + 1);
//            modifyLookVideoInfo.setModifyTime(DateUtil.getCurDate());
//
//            lookVideoInfoService.modifyLookArticleInfo(modifyLookVideoInfo);
//
//        }
//
//        //记录新的查看次数
//        NewLookVideoCountInfo newLookVideoCountInfo = new NewLookVideoCountInfo();
//        newLookVideoCountInfo.setUserId(lookVideoInfo.getUserId());
//        newLookVideoCountInfo.setOtherUserId(lookVideoInfo.getOtherUserId());
//
//        NewLookVideoCountInfo newLookVideoCountInfoInDB = newLookVideoCountInfoService.getNewLookVideoInfo(newLookVideoCountInfo);
//        if (newLookVideoCountInfoInDB != null && newLookVideoCountInfoInDB.getId() != null) {
//
//            NewLookVideoCountInfo updateNewLookVideoCountInfo = new NewLookVideoCountInfo();
//            updateNewLookVideoCountInfo.setId(newLookVideoCountInfoInDB.getId());
//            updateNewLookVideoCountInfo.setLookCount(newLookVideoCountInfoInDB.getLookCount() + 1);
//            updateNewLookVideoCountInfo.setModifyTime(DateUtil.getCurDate());
//
//            newLookVideoCountInfoService.modifyNewLookVideoInfo(updateNewLookVideoCountInfo);
//
//        } else {
//
//            newLookVideoCountInfo.setLookCount(1);
//            newLookVideoCountInfo.setModifyTime(DateUtil.getCurDate());
//            newLookVideoCountInfo.setCreateTime(DateUtil.getCurDate());
//
//            newLookVideoCountInfoService.recordNewLookVideoInfo(newLookVideoCountInfo);
//
//        }

        //发送微信公众号通知
        //lookPunchClockVideoAsyncTask.sendUserPunchClockVideoBeLookedWxPushMsg(lookVideoInfo.getUserId(), lookVideoInfo.getOtherUserId(), punchClockVideoInfo, lookUserNickName);

//        return 0;
//    }

    @Override
    public List<CombinedVideoInfoByVideoBrand> tempQueryThumbnailNullInfo() {
        return articleInfoMapper.tempQueryThumbnailNullInfo();
    }

    @Override
    public int getUserSharedVideoCount(Integer userId) {

        int userSharedVideoCount = 0;

        Object userSharedVideoCountObj = redisCacheUtil.getCacheObject("userSharedVideoCount" + userId);
        if (userSharedVideoCountObj != null) {
            userSharedVideoCount = (Integer)userSharedVideoCountObj;
        } else {
            userSharedVideoCount = Optional.ofNullable(articleInfoMapper.queryUserSharedVideoCount(userId)).orElse(0);
        }

        //因为前端只需要知道用户是否已经分享过文章，故只要查询到用户分享数目大于1，则缓存
        if (userSharedVideoCount > 1) {

            redisCacheUtil.setCacheObject("userSharedVideoCount" + userId, userSharedVideoCount, 2592000);

        }

        return userSharedVideoCount;
    }

    @Override
    public PageInfo<VideoListShowInfo> getVideoInfoByVideoTypeForHotScore(int pageNum, int pageSize, Integer articleTypeId, Integer articleHotValue) {

        PageHelper.startPage(pageNum, pageSize);
        List<VideoListShowInfo> articleInfoByVideoTypeList = articleInfoMapper.queryVideoInfoByVideoTypeForHotScore(articleTypeId, articleHotValue);

        return new PageInfo<VideoListShowInfo>(articleInfoByVideoTypeList);
    }

    @Override
    public PageInfo<VideoListShowInfo> getVideoInfoByVideoBrandForHotScore(int pageNum, int pageSize, Integer articleBrandId, Integer articleHotValue) {

        PageHelper.startPage(pageNum, pageSize);
        List<VideoListShowInfo> articleInfoByVideoBrandList =  articleInfoMapper.queryVideoInfoByVideoBrandForHotScore(articleBrandId, articleHotValue);

        return new PageInfo<VideoListShowInfo>(articleInfoByVideoBrandList);
    }

    @Override
    public List<VideoListShowInfo> getVideoInfoByVideoTypeForHotScoreBySpecialSize(Integer articleTypeId, Integer articleHotValue, Integer recordSize) {
        return articleInfoMapper.queryVideoInfoByVideoTypeForHotScoreBySpecialSize(articleTypeId, articleHotValue, recordSize);
    }

    @Override
    public VideoInfo getUserAddedWxVideoInfoByTitle(Integer userId, String articleTitle) {
        return articleInfoMapper.queryUserAddedWxVideoInfoByTitle(userId, articleTitle);
    }

    @Override
    public String generateCustomerPagePromptText(Integer userId, int totalLookCount) {

        CustomerPagePromptInfo customerPagePromptInfo = (CustomerPagePromptInfo) redisCacheUtil.getCacheObject(userId + "customerPagePushTimesKey");

        int customerPagePushTimes = 1;
        if (customerPagePromptInfo == null) {
            customerPagePromptInfo = new CustomerPagePromptInfo();
            customerPagePromptInfo.setLastPushTime(1);
            customerPagePromptInfo.setNextPushTime(2);

            String pushDate = DateTime.now().toString("yyyy-MM-dd");
            customerPagePromptInfo.setLastPushDate(pushDate);

            redisCacheUtil.setCacheObject(userId + "customerPagePushTimesKey", customerPagePromptInfo, 604800);

        } else {

            String pushDate = customerPagePromptInfo.getLastPushDate();

            String nowDate = DateTime.now().toString("yyyy-MM-dd");

            if (nowDate.equals(pushDate)) {

                customerPagePushTimes = customerPagePromptInfo.getLastPushTime();

            } else {

                customerPagePushTimes = customerPagePromptInfo.getNextPushTime();

                CustomerPagePromptInfo nextCustomerPagePromptInfo = new CustomerPagePromptInfo();

                nextCustomerPagePromptInfo.setLastPushTime(customerPagePromptInfo.getNextPushTime());
                nextCustomerPagePromptInfo.setNextPushTime(customerPagePromptInfo.getNextPushTime() + 1);
                nextCustomerPagePromptInfo.setLastPushDate(nowDate);

                redisCacheUtil.setCacheObject(userId + "customerPagePushTimesKey", nextCustomerPagePromptInfo, 604800);

            }

        }

        StringBuffer promptText = new StringBuffer();
        if (customerPagePushTimes == 1 || customerPagePushTimes == 8) {

            promptText.append("你已错过");
            promptText.append(totalLookCount);
            promptText.append("次跟进机会\n");
            promptText.append("有多少机会可以继续错过？");

        } else if (customerPagePushTimes == 2) {

            if (totalLookCount > 5) {

                promptText.append("有");
                promptText.append(totalLookCount);
                promptText.append("个意向客户看了你的文章\n");
                promptText.append("精准机会就这么错过？");

            } else {

                promptText.append("有意向客户看了你的文章\n");
                promptText.append("不能错过这么精准的机会哦~");

            }

        } else if (customerPagePushTimes == 3) {

            //获取用户选中的品牌
            BrandInfo selectBrandInfo = userBrandInfoService.getUserSelectBrandInfo(userId);

            if (selectBrandInfo == null || selectBrandInfo.getId() == null || selectBrandInfo.getUserId() != null) {

                promptText.append("你的同行都在追踪客户哦\n");
                promptText.append("你也要行动哦，不能被动等待");

            } else {
                int brandId = selectBrandInfo.getId();
                int brandSubCount = userBrandInfoService.getBrandSubCount(brandId);
                String brandName = selectBrandInfo.getBrandName();

                if (brandSubCount < 30) {
                    promptText.append(brandName);
                    promptText.append(" 的小伙伴都在追踪客户哦\n");
                    promptText.append("你也要行动哦，不能被动等待");
                } else {

                    promptText.append(brandName);
                    promptText.append("已有 ");
                    promptText.append(brandSubCount * 15);
                    promptText.append(" 人在追踪客户哦\n");
                    promptText.append("你也要行动哦，不能被动等待");

                }

            }

        } else if (customerPagePushTimes == 4) {

            promptText.append("最容易成交的就是朋友圈客户啊~\n");
            promptText.append("先从身边的资源开始吧");

        } else if (customerPagePushTimes == 5) {

            promptText.append("已有 ");
            promptText.append(totalLookCount);
            promptText.append(" 人看了你的文章\n");
            promptText.append("你还说没客户资源吗？");

        } else if (customerPagePushTimes == 6) {

            promptText.append("天天想着加好友是没错\n");
            promptText.append("可了解客户需求才最关键呢");

        } else if (customerPagePushTimes == 7) {

            //获取用户选中的品牌
            BrandInfo selectBrandInfo = userBrandInfoService.getUserSelectBrandInfo(userId);

            if (selectBrandInfo == null || selectBrandInfo.getId() == null || selectBrandInfo.getUserId() != null) {

                promptText.append("有其他伙伴开通会员了哦\n");
                promptText.append("你还在茫然的想客户在哪...");

            } else {

                int brandId = selectBrandInfo.getId();
                int brandSubCount = userBrandInfoService.getBrandSubCount(brandId);
                String brandName = selectBrandInfo.getBrandName();

                if (brandSubCount < 100) {

                    promptText.append(brandName);
                    promptText.append(" 有 ");
                    promptText.append(1 + brandSubCount / 10);
                    promptText.append(" 位伙伴开会员了哦\n");
                    promptText.append("你还在茫然的想客户在哪...");

                } else {

                    int num = ToolUtil.randomNum(11, 29);

                    promptText.append(brandName);
                    promptText.append(" 有 ");
                    promptText.append(num + brandSubCount / 20);
                    promptText.append(" 位伙伴开会员了哦\n");
                    promptText.append("你还在茫然的想客户在哪...");

                }

            }

        }

        return promptText.toString();
    }

}
